# --------------------------------------------------------
#  Copyright (C) 2004-2019 by EMGU Corporation. All rights reserved.
# --------------------------------------------------------

IF((HAVE_WINDESKTOP_X64 OR HAVE_LINUX) AND (NOT "${DOTNET_EXECUTABLE}" STREQUAL "DOTNET_EXECUTABLE-NOTFOUND"))
  PROJECT(Emgu.TF.CodeGen.NetCore)

  BUILD_DOTNET_PROJ(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.csproj"  "" ALL)

  IF(HAVE_WINDESKTOP_X64 AND WIN32)
    ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} 
	POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/../lib/x64" "${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.TF/x64"
	COMMAND ${DOTNET_EXECUTABLE} "${PROJECT_NAME}.dll"
	WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.TF/")
  ELSEIF(HAVE_LINUX AND (NOT (WIN32 OR APPLE)))
    ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} 
	POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/../lib/libtfextern.so" "${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.TF"
	COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/../lib/libtensorflow_framework.so" "${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.TF"
	COMMAND ${DOTNET_EXECUTABLE} "${PROJECT_NAME}.dll"
	WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.TF/")
  ENDIF()

  ADD_DEPENDENCIES(${PROJECT_NAME} Emgu.TF.Netstandard Emgu.TF.Protobuf.Netstandard)
ENDIF()
